#Vary R0 and Nstar

source("/scratch/jc227089/evo-dispersal/evostoch/evostochFunctions.R")
setwd("/scratch/jc227089/evostochData/")


args=(commandArgs(TRUE))

#evaluate the arguments
# input arguments will be R0, Nstar
for(i in 1:length(args)) {
	 eval(parse(text=args[[i]]))
}

#R0<-4
#Nstar<-10
#repn<-1

fID<-paste(R0, Nstar, repn, sep="_")
spX<-0
R0<-R0
a<-(R0-1)/Nstar
n<-20
ngens<-30
Hmean<-0
Dmean<-log(4)
h2H<-0.3
h2D<-h2H
VPH<-0.2
VPD<-0.2
nreps<-10


out<-vector(mode="list", length=2*nreps)
pop<-init.inds2D(n, spX, Hmean, Dmean, h2H, h2D, VPH, VPD)
for (ii in 1:nreps){
	print(ii)
	repl<-mother.fed2D(pop, n=n, spX=spX, a=a, R0=R0, ngens=ngens, Hmean=Hmean, 
		Dmean=Dmean, h2H=h2H, h2D=h2D, VPH=VPH, VPD=VPD, evovar=TRUE, Plot=FALSE)
	out[[ii]]<-repl
}
#Turn evolution off
h2H<-0
h2D<-h2H
pop[,"H"]<-Hmean
pop[,"D"]<-Dmean

for (ii in (nreps+1):(2*nreps)){
	print(ii)
	repl<-mother.fed2D(pop, n=n, spX=spX, a=a, R0=R0, ngens=ngens, Hmean=Hmean, 
		Dmean=Dmean, h2H=h2H, h2D=h2D, VPH=VPH, VPD=VPD, evovar=TRUE, Plot=FALSE)
	out[[ii]]<-repl
}
print(fID)
  	
save(out, file=paste("evostoch_2D_varR0_varNst", fID, ".RData", sep=""))

